<template>
	<view class="main">
		<view class="email flex_align mt30">
			<view class="fz38 mr30">
				邮箱
			</view>
			<u-input placeholder="请输入邮箱地址" border="none" v-model="email"></u-input>
		</view>
		<view class="tips mt20">
			请填写真实邮箱，用于接收台账报表，可在个人中心--个人资料进行修改
		</view>

		<view class="button" hover-class="none" @click="emailEdit()">确定</view>

	</view>
</template>

<script>
import { setEmail } from '@/api/my.js'
export default {
	data() {
		return {
			email: '',
		};
	},
	onLoad(e) {
		if (e.email) {
			this.email = e.email
		}
	},
	methods: {
		emailEdit() {
			var requestData = {
				email: this.email
			}

			setEmail(requestData).then(res => {
				if (res.code == 1) {
					uni.showToast({
						title: '邮箱设置成功',
					});
					uni.setStorageSync("email", this.email)
					setTimeout(() => {
						uni.navigateBack({
							delta: 1 // 返回的页面数
						})
					}, 2000)
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.main {
	background: #FAFAFA !important;

	.email {
		padding: 0 20rpx;
		width: 100%;
		height: 112rpx;
		background-color: #fff;
	}

	.tips {
		margin: 0 auto;
		width: 683rpx;
		height: 80rpx;
		font-size: 24rpx;
		color: #9E9E9E;
	}

	.button {
		position: absolute;
		top: 500rpx;
		left: 50%;
		transform: translateX(-50%);
		text-align: center;
		width: 651rpx;
		height: 95rpx;
		line-height: 95rpx;
		background: #1C87F3;
		border-radius: 68rpx;
		color: #fff;
	}
}
</style>
